<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/12
 * Time: 21:13
 */

namespace App\Http\Controllers\Admin;


use App\Models\CompanyApply;

class CompanyController extends BaseController
{
    public function __construct()
    {
        $this->middleware('verify.admin');
    }

    public function index()
    {
        $data['auth'] = $this->getUserAuth();
        return view('system.company-manager', $data);
    }

    public function getLists()
    {
        $lists = [];
        $companyApplyModel = CompanyApply::all();
        if (!empty($companyApplyModel)) {
            $lists = $companyApplyModel->toArray();
        }
        return successJson($lists);
    }

    public function show($id)
    {
        $detail = [];
        $companyApplyModel = CompanyApply::findOrFail($id);
        if (!empty($companyApplyModel)) {
            $detail = $companyApplyModel->toArray();
        }
        $data['details'] = $detail;
        $data['auth'] = $this->getUserAuth();
        return view('system.company-detail', $data);
    }

    public function delete($id)
    {
        $res = CompanyApply::destroy($id);
        if ($res) {
            return successJson('','删除成功');
        } else {
            return successJson('', '删除失败');
        }
    }
}